
%% Data plots
clear all;addpath('auxiliar'); addpath('Simulated_Datasets');
 [num,tex] = xlsread('Output_PViip_NonPerf_9917.xls','Sheet1');

pv=num(:, 2);
pub=num(:, 4);
total=pv+pub;
spread=num(:, 5);
nonperf=num(:, 3);
time=1999:2017;

%% FIGURE 1: The Importance of composition, total debt and spreads
figure

plot(time(1,1:17),total(1:17,1)*100,'Linewidth',3,'Color','k'); hold on;
%plot(time(1,1:17),pv(1:17,1)*100,'Linewidth',3,'Color','b'); hold on;
ylabel('Percent of GDP');
 ylim([0.0 120]);
yyaxis right
plot(time(1,1:17),max(spread(1:17,1),0)*100,'Linewidth',4,'Color','r','LineStyle',':'); hold on;
ylabel('Percent');
 ylim([0.0 5.0]);
Hlegend=legend('Total debt','Spread on public debt','Location','northwest'); set(Hlegend,'Interpreter','Latex')
xlim([1999 2015]);legend boxoff
xticks([1999 2003 2007 2011 2015])
yticks([0 1 2 3 4 5])
xticklabels({'1999','2003','2007','2011','2015'})
yticklabels({'0','1 ','2 ','3 ','4' ,'5 '})
ax = gca;
ax.YAxis(1).Color = 'k';
ax.YAxis(2).Color = 'r';

set(gca, 'FontSize',15,'box','off')
exportfig(gcf,'Plots\Fact1_TotalDebtSpreads.eps','color','cmyk','resolution',1600)

%% %% FIGURE 2: Private Origin of the crisis
figure
plot(time(1,1:17),pv(1:17,1)*100,'Linewidth',3,'Color','b'); hold on;
ylabel('Percent of GDP');
 ylim([0.0 80]);
yyaxis right
plot(time(1,1:17),nonperf(1:17,1)*100,'Linewidth',2,'Color','b','LineStyle','--'); hold on;
ylabel('Percent');
 ylim([0.0 10]);
Hlegend=legend('Private debt','Non-performing loans','Location','northwest'); set(Hlegend,'Interpreter','Latex')
xlim([1999 2015]);legend boxoff
xticks([1999 2003 2007 2011 2015])
xticklabels({'1999','2003','2007','2011','2015'})
yticks([0 2 4 6 8 10])
yticklabels({'0' '2','4','6','8','10'})
ax = gca;
ax.YAxis(1).Color = 'k';
ax.YAxis(2).Color = 'b';
set(gca, 'FontSize',15,'box','off')%,'Color','w', 'XColor','k', 'defaultAxesColorOrder',[left_color; right_color]);
exportfig(gcf,'Plots\Fact2_PrivateOrigin.eps','color','cmyk','resolution',1600)


%% Figure3 
figure

plot(time(1,1:17),pv(1:17,1)*100,'Linewidth',3,'Color','b'); hold on;
plot(time(1,1:17),pub(1:17,1)*100,'Linewidth',3,'Color','r'); hold on;
ylabel('Percent of GDP');
 ylim([0.0 80]);
Hlegend=legend('Private debt','Public debt','Location','northwest'); set(Hlegend,'Interpreter','Latex')
xlim([1999 2015]);legend boxoff
xticks([1999 2003 2007 2011 2015])
yticks([0 20 40 60 80])
xticklabels({'1999','2003','2007','2011','2015'})
yticklabels({'0' '20','40','60','80'})
ax = gca;
ax.YAxis(1).Color = 'k';

set(gca, 'FontSize',15,'box','off')
exportfig(gcf,'Plots\Fact3_PrivatePublic.eps','color','cmyk','resolution',1600)
